﻿namespace Istace.Framework.Mapping.Core.Interfaces
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IIndexedRepository<T> : IIndexedRepository
    {
        /// <summary>
        /// AddInstance an object to the repository
        /// </summary>
        /// <param name="key">The key used to index the objectToAdd</param>
        /// <param name="objectToAdd">The object to index</param>
        void AddInstance(string key, T objectToAdd);

        /// <summary>
        /// AddInstance an object to the repository
        /// </summary>
        /// <param name="key">The key used to index the objectToAdd</param>
        /// <param name="objectToAdd">The object to index</param>
        /// <param name="replaceIfExist">If true, if the object already exist, the existing instance is replaced by the new one</param>
        void AddInstance(string key, T objectToAdd, bool replaceIfExist);

        /// <summary>
        /// GetInstance an indexed object based on the given key
        /// </summary>
        /// <param name="index">The key used to index the object</param>
        /// <returns>The stored instance</returns>
        T GetInstance(string index);

        /// <summary>
        /// Try to add an object of T to the data dictionnary indexed on the given key 
        /// </summary>
        /// <param name="key">The key used to index the object within the repository</param>
        /// <param name="objectToAdd">The object to add indexed on key</param>
        /// <returns>True if</returns>
        bool TryAddInstance(string key, T objectToAdd);

        /// <summary>
        /// Try to add an object of T to the data dictionnary indexed on the given key 
        /// </summary>
        /// <param name="key">The key used to index the object within the repository</param>
        /// <param name="objectToAdd">The object to add indexed on key</param>
        /// <param name="replaceIfExist">If the object is already indexed, we will replace the existing instance</param>
        /// <returns>True if</returns>
        bool TryAddInstance(string key, T objectToAdd, bool replaceIfExist);

        /// <summary>
        /// Try to get the object associated with the given index
        /// </summary>
        /// <param name="index">Index key used to identify the object</param>
        /// <param name="output">Object to retreive</param>
        /// <returns>True if the get succeed, Else false</returns>
        bool TryGetInstance(string index, out T output);
    }

    /// <summary>
    /// 
    /// </summary>
    public interface IIndexedRepository
    {

    }
}
